<?php
	/** Tuto http://www.sebastien-giroux.com/2010/10/twig-tutorial/ **/
	require("include/includes.php");
	/*
		init de twig déplacé dans './include/lib/startTwig.lib.php' appelé dans includes.php
	*/
	/***************** DEBUT TEST CLASS ******************/
/*
	// CHARACTER
	echo "<br/><br/>TEST CHARACTER<br/><br/>";
	$c = new Character(2);
//	$c->setName($c->getName()."2");
	$c->save();
	echo "Nom = ".$c->getName()."<br/>";
	$characters = Character::getAll();
	foreach($characters as $c)
		echo "[GET all] Name = ".$c->getName()."<br/>";

	// PLAYER
	echo "<br/><br/>TEST PLAYER<br/><br/>";
	$p2 = new Player(Array("nickname" => 'moi'));
	echo "[new Player(ARRAY)] Nom = ".$p2->getNickname()."<br/>";
	$p = new Player(1);
	//$p->setNickname("Ikram");
	if($p->save()==false)
		echo "pas foncitonn";
	
	echo "Nom = ".$p->getNickname()."<br/>";
	$players = Player::getAll();
	foreach($players as $p)
		echo "[GET all] Id = ".$p->getId()."<br/>";
	
	
	// PROOF
	echo "<br/><br/>TEST PROOF<br/><br/>";
	$p = new Proof(1);
	//$p->setUrl($p->getUrl()."moi");
	if($p->save()==true)
		echo "Modification effectué";
	else
		echo "Echec effectué";
		
	echo "Id = ".$p->getId()."<br/>";
	$proves = Proof::getAll();
	foreach($proves as $p)
		echo "[GET all] Id = ".$p->getId()."<br/>";	

	// RECORD
	echo "<br/><br/>TEST RECORD<br/><br/>";
	$r = new Record(1);
//	$r->setIp("127.0.0.4");
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = Record::getAll();
	foreach($records as $r)
		echo "[GET all] Id = ".$r->getId()."<br/>";

	// TRACK MODE
	echo "<br/><br/>TEST TRACK MODE<br/><br/>";
	$r = new TrackMode(1);
	$r->setMode("classic2");
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = TrackMode::getAll();
	foreach($records as $r)
		echo "[GET all] Mode = ".$r->getMode()."<br/>";
		
	// TRACK TYPE
	echo "<br/><br/>TEST TRACK TYPE<br/><br/>";
	$r = new TrackType(1);
	//$r->setName("Course 2");
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = TrackType::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getName()."<br/>";
		
	// TRACK NAME
	echo "<br/><br/>TEST TRACK NAME<br/><br/>";
	$r = new TrackName(1);
//	$r->setName("Crash Cove2");
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = TrackName::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getName()."<br/>";
		
	// TRACK Version
	echo "<br/><br/>TEST Version<br/><br/>";
	$r = new Version(1);
//	$r->setName("PAL2");
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = Version::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getName()."<br/>";
	
	// TRACK World Records
	echo "<br/><br/>TEST World Records<br/><br/>";
	$r = new WorldRecords(1);
	$record = new Record(1);
	$r->setRecord($record); // Utiliser le setter
	$r->save();
	
	echo "Id = ".$r->getId()."<br/>";
	$records = WorldRecords::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getId()."<br/>";

	// Country
	echo "<br/><br/>TEST Country<br/><br/>";
	$r = new Country(1);
	echo "Id = ".$r->getId()."<br/>";
	$records = Country::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getName()."<br/>";
		
	// STANDARD
	echo "<br/><br/>TEST STANDARD<br/><br/>";
	$r = new Standard(1);
	$r->setTime(10001);
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = Standard::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getTrackName()->getName()."<br/>";
	
	// RecordsHistory
	echo "<br/><br/>TEST Records History<br/><br/>";
	$r = new RecordsHistory(1);
	$r->setDate("2011-03-14 17:48:59");
	$r->save();
	echo "Id = ".$r->getId()."<br/>";
	$records = RecordsHistory::getAll();
	foreach($records as $r)
		echo "[GET all] Name = ".$r->getTrackName()->getName()."<br/>";
			
	echo "<br/><br/>";
	
	// Login / Logout
	echo "<br/><br/>TEST Login/Logout<br/><br/>";
	if(isset($_SESSION['user']))
		echo "I'm logged as ".$_SESSION['user']." :)<br/>";
	else
		echo "I'm NOT logged<br/>";
	
	echo "<br/><br/>";

*/	
	/***************** FIN TEST CLASS ******************/
	$template = $twig->loadTemplate('testTemplate.html');
	
	$template->display(array(
		'pageTitle' => 'Premiere page ac TWIG',
		'contenu' => 'Contenu de la page'
	));

?>